//
//  UIBarButtonItem+Extensions.swift
//  DLSwift微博
//
//  Created by 丁浪涛 on 2016/11/9.
//  Copyright © 2016年 丁浪涛. All rights reserved.
//

import UIKit

extension UIBarButtonItem
{
    
    //便利构造函数
    convenience init(tite: String,fontSize: CGFloat = 16,target: AnyObject?,action: Selector ,isBackButton: Bool = false )
    {
    
        let btn :UIButton  =  UIButton.cz_textButton(tite, fontSize: fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        
        if isBackButton {
            let imageName = "navigationbar_back_withtext"
            btn.setImage(UIImage(named: imageName), for: .normal)
            btn.setImage(UIImage(named : imageName + "_highlighted"), for: .highlighted)
            btn.sizeToFit()
        }
        btn.addTarget(target, action: action, for: .touchUpInside)
      
        self.init(customView:btn)
    }

}
